
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>查询语句和转变 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    GraphQL 介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="chapter1.html">
            
                <a href="chapter1.html">
            
                    
                    查询语句和转变
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >查询语句和转变</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x548C;&#x8F6C;&#x53D8;&#xFF08;queries-and-mutations&#xFF09;">&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x548C;&#x8F6C;&#x53D8;&#xFF08;Queries and Mutations&#xFF09;</h1>
<p>&#x5728;&#x8FD9;&#x4E00;&#x9875;&#x91CC;&#xFF0C;&#x4F60;&#x5C06;&#x4F1A;&#x4E86;&#x89E3;&#x5230;&#x5982;&#x4F55;&#x5728;&#x4E00;&#x4E2A;GraphQL&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x67E5;&#x8BE2;&#x3002;</p>
<h3 id="fields">Fields</h3>
<p>&#x6700;&#x7B80;&#x5355;&#x6765;&#x8BF4;&#xFF0C;GraphQL&#x5C31;&#x662F;&#x5173;&#x4E8E;&#x8BE2;&#x95EE;&#x5BF9;&#x8C61;&#x91CC;&#x7279;&#x5B9A;&#x7684;fields&#x3002;&#x8BA9;&#x6211;&#x4EEC;&#x4ECE;&#x770B;&#x4E00;&#x4E2A;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x7684;&#x8BED;&#x53E5;&#x548C;&#x8FD0;&#x884C;&#x4E4B;&#x540E;&#x83B7;&#x5F97;&#x7684;&#x7ED3;&#x679C;&#x5F00;&#x59CB;&#xFF1A;</p>
<pre><code class="lang-js">{
  hero {
    name
  }
}
</code></pre>
<pre><code class="lang-js">{
  <span class="hljs-string">&quot;data&quot;</span>: {
    <span class="hljs-string">&quot;hero&quot;</span>: {
      <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;R2-D2&quot;</span>
    }
  }
}
</code></pre>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x7ACB;&#x5373;&#x770B;&#x89C1;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x6709;&#x5B8C;&#x5168;&#x4E00;&#x6837;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x3002;&#x8FD9;&#x5BF9;&#x4E8E;GraphQL&#x6765;&#x8BF4;&#x662F;&#x5F88;&#x6709;&#x5FC5;&#x8981;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x4F60;&#x603B;&#x662F;&#x5F97;&#x5230;&#x4F60;&#x6240;&#x60F3;&#x8981;&#x7684;&#xFF0C;&#x800C;&#x4E14;&#x670D;&#x52A1;&#x5668;&#x51C6;&#x786E;&#x7684;&#x77E5;&#x9053;&#x5BA2;&#x6237;&#x7AEF;&#x8981;&#x6C42;&#x7684;fields&#x662F;&#x4EC0;&#x4E48;&#x3002;</p>
<p>Field <em>name</em> &#x8FD4;&#x56DE;&#x4E00;&#x4E2A; <em>String </em>&#x7C7B;&#x578B;&#xFF0C;&#x5728;&#x8FD9;&#x4E2A;&#x60C5;&#x51B5;&#x4E0B;&#x662F;&#x661F;&#x9645;&#x4E89;&#x9738;&#x4E3B;&#x89D2;&#x82F1;&#x96C4;&#x7684;&#x540D;&#x5B57;<em>&#x201C;R2-D2&#x201D;</em>&#x3002;</p>
<blockquote>
<p>&#x5BF9;&#x4E86;&#xFF0C;&#x8FD8;&#x6709;&#x4E00;&#x4EF6;&#x4E8B; - &#x4E0A;&#x9762;&#x7684;&#x8BED;&#x53E5;&#x662F;&#x4EA4;&#x4E92;&#x6027;&#xFF08;interactive&#xFF09;&#x7684;&#x3002;&#x8A00;&#x4E0B;&#x4E4B;&#x610F;&#x4F60;&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x4F60;&#x7684;&#x559C;&#x597D;&#x6765;&#x83B7;&#x53D6;&#x65B0;&#x7684;&#x7ED3;&#x679C;&#x3002;&#x8BD5;&#x7740;&#x5728;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x91CC;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A; <em>appearsIn</em> field &#x5230; <em>hero</em> &#x5BF9;&#x8C61;&#x91CC;&#xFF0C;&#x7136;&#x540E;&#x770B;&#x65B0;&#x7684;&#x7ED3;&#x679C;</p>
</blockquote>
<p>&#x5728;&#x4E4B;&#x524D;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x662F;&#x67E5;&#x8BE2;&#x82F1;&#x96C4;&#x7684;&#x540D;&#x5B57;&#x5BF9;&#x5E94; String &#x7684;&#x56DE;&#x9988;&#xFF0C;&#x4F46;&#x662F; fields &#x4E5F;&#x80FD;&#x6307;&#x5411;&#x5BF9;&#x8C61;&#x3002;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x91CC;&#xFF0C;&#x4F60;&#x80FD;&#x7ED9;&#x90A3;&#x4E2A;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; fields &#x7684; <em>sub-selection&#x3002;GraphQL</em>&#x8BED;&#x53E5;&#x80FD;&#x904D;&#x5386;&#x76F8;&#x5173;&#x8054;&#x7684;&#x5BF9;&#x8C61;&#x548C;&#x5B83;&#x4EEC;&#x7684; fields&#xFF0C;&#x8BA9;&#x5BA2;&#x6237;&#x7AEF;&#x80FD;&#x591F;&#x5728;&#x4E00;&#x6B21;&#x8BF7;&#x6C42;&#x4E2D;&#x83B7;&#x53D6;&#x5230;&#x591A;&#x4E2A;&#x76F8;&#x5173;&#x6570;&#x636E;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x50CF;&#x4F20;&#x7EDF;&#x7684;REST&#x67B6;&#x6784;&#x91CC;&#x9700;&#x8981;&#x53CD;&#x590D;&#x8BF7;&#x6C42;&#x591A;&#x6B21;&#x3002;</p>
<pre><code>{
  hero {
    name
    # Queries can have comments!
    friends {
      name
    }
  }
}
</code></pre><pre><code>{
  &quot;data&quot;: {
    &quot;hero&quot;: {
      &quot;name&quot;: &quot;R2-D2&quot;,
      &quot;friends&quot;: [
        {
          &quot;name&quot;: &quot;Luke Skywalker&quot;
        },
        {
          &quot;name&quot;: &quot;Han Solo&quot;
        },
        {
          &quot;name&quot;: &quot;Leia Organa&quot;
        }
      ]
    }
  }
}
</code></pre><p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;<em>friends</em> field &#x8FD4;&#x56DE;&#x4E86;&#x4E00;&#x7EC4;&#x6570;&#x636E;&#x5355;&#x5143;&#x3002;&#x5BF9;&#x4E8E;GraphQL&#x8BED;&#x53E5;&#x6765;&#x8BF4;&#xFF0C;&#x5355;&#x6570;&#x636E;&#x5143;&#x8FD8;&#x662F;&#x4E00;&#x4E2A;&#x5217;&#x8868;&#x7684;&#x6570;&#x636E;&#x5143;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x57FA;&#x4E8E;&#x8868;&#x8FBE;&#x7684;&#x6570;&#x636E;&#x6A21;&#x5F0F;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x6700;&#x540E;&#x4F1A;&#x83B7;&#x5F97;&#x7684;&#x662F;&#x54EA;&#x4E00;&#x4E2A;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev navigation-unique" aria-label="Previous page: GraphQL 介绍">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"查询语句和转变","level":"1.2","depth":1,"previous":{"title":"GraphQL 介绍","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter1.md","mtime":"2017-02-15T11:35:55.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-02-15T11:46:59.447Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

